I'm challenged by the need to replace hyphens in Object Level with decimals for compatibility with another app. So far I haven't been successful. |
Re: substitute character |
Re: substitute character
Try the following code snippet as an example - this snippet also gets rid of the leading zero character which is redundant if all you're trying to do is convert the Object Number into a paragraph number.
Object o = current
string paraNum = number( o )
// Set up regular expression to look for "0-". The "(.*)" bits will return the parts of the
// matched string on each side of the "0-"
Regexp findZeroDash = regexp "(.*)0-(.*)"
while ( findZeroDash paraNum ) {
// If the regular expression was matched then concatenate the parts of the para num on
// each side of "0-"
paraNum = paraNum[match 1] paraNum[match 2]
}
print paraNum
Paul Miller
|
Re: substitute character Paul, -E- DXL: <Line:17> incorrectly concatenated tokens -E- DXL: <Line:17> undeclared variable (paraNummatch) cannot figure out what paraNummatch should be/do. Tried paranum match 1 but still get the token error. Commented out the line and correctly get first character of Object Number. Suggestion? |
Re: substitute character steelemic - Thu Feb 02 20:04:48 EST 2012 |
Re: substitute character steelemic - Thu Feb 02 20:04:48 EST 2012 Although I note that the error you have reported suggests that the square braces that are around each of the two match() functions are missing - maybe you don't see those square braces in your browser so this could be a browser issue or a copy-n-paste issue. Also, there's been some fiddling about with how the DXL Regular Expressions work in DOORS over past previous versions. The match() function is used to carve out specific chunks of the regular expression, the delimiter between chunks is loosely the literal character or text strings that you're searching for. Hard to explain here, I would recommend you have a look at the DXL reference Manual under the heading path "General language facilities">"Regular Expressions">"Match" - there's an example code snippet to help demonstrate how the match() function works. Regular Expressions are a specialist area to which I only occasionally dabble in and often get PERL or UNIX script writers to help as Regular Expression definitions are a staple for these people (I believe copious amounts of Coca Cola, Pizza and late nights help!). Paul Miller Melbourne, Australia |
Re: substitute character SystemAdmin - Thu Feb 02 20:41:40 EST 2012 Paul Miller Melbourne, Australia Paul Miller Melbourne, Australia |
Re: substitute character The following code worked. Two small changes to get behavior I was looking for. // get Object Number string paraNum = number ( obj ) // Set up regular expression to look for "0-". The "(.*)" bits will return the parts of the // matched string on each side of the "0-" Regexp findZeroDash = regexp "(.*)0-(.*)" while ( findZeroDash paraNum ) { // If the regular expression was matched then concatenate the parts of the para num on // each side of "0-" // Change "0-" to "0." // example 1.0-1 becomes 1.0.1 paraNum = paraNummatch 1 "0." paraNummatch 2 } display paraNum |